package org.example.weboj.controller;

import org.example.weboj.dto.ProblemDTO;
import org.example.weboj.entity.Problems;
import org.example.weboj.service.IProblemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wza
 * @since 2025-04-03
 */
@RestController
@RequestMapping("/problems")
public class ProblemsController {
    @Autowired
    private IProblemsService problemsService;

    // 直接调用MyBatis-Plus内置方法
    @GetMapping("/{id}")
    public ProblemDTO getById(@PathVariable Long id) {
        return problemsService.getProblemDTOById(id);
    }

    @GetMapping
    public List<ProblemDTO> getAll() {
        return problemsService.getAllProblemDTOs();
    }

}
